#include <iostream>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

using namespace std;

int main(int argc, char **argv)
{
    int numenter=0;

    FILE *fp = fopen("/devlops/test.txt", "r");
    if (fp == NULL)
    {
        perror("open file error");
        exit(1);
    }
    int c;

    cout<<"beging file position is: "<<ftell(fp)<<endl;
    while((c = fgetc(fp)) != -1)
    {
        if(c == '\n') break;
        cout<<"file position is: "<<ftell(fp)<<endl;
        cout<<"read: "<<(char)c<<endl;
        numenter++;
    }

    cout<<"enter nums is: "<<numenter<<endl;
    
    
    

    return 0;
}